{include file='common/header'}

<div class="content">

    <div class="panel">
        <div class="logo"><img src="" /></div>
        <div class="sign">
            <h2>登录</h2>
            <form id="login_form">
                <input type="text" name="username" placeholder="用户名" />
                <input type="password" name="password" placeholder="密码" />
                <input type="button" class="btn_info" name="login" value="登陆" />
            </form>
            <p class="notice">没有账号?<a href="{:url('index/register')}">现在注册</a></p>
        </div>
    </div>

</div>

{include file='common/footer'}

<script language="JavaScript">
    //注册
    $('input[name=login]').click(function(){
        var form = $('#login_form').serializeArray();
        form.push({name:'uuid', value:navigator.userAgent});
        for(var i = 0; i < form.length; i++){
            if(form[i].name == 'username'){
                if(form[i].value.length < 3){
                    return layer.alert('用户名不能小于3位.', {icon:2});
                }
            }
            if(form[i].name == 'password'){
                if(form[i].value.length <= 0){
                    return layer.alert('密码不能为空.', {icon:2});
                }
            }
        }
        var index = layer.load(1);
        $.post("{:url('Ajax/login')}", form, function(res){
            if(res.status == 1){
                var req = {};
                req.params = {username:res.data.username};
                req.action = 'user/checkintact';
                $.post(REQUEST_URL, req, function(res){
                    layer.close(index);
                    if(res.code == 3){      //提示设置昵称和头像
                        layer.alert('您的信息不完整,请补充完整', function(){
                            location.assign("{:url('index/supplement')}");
                        });
                    }else{
                        location.assign("{:url('index/index')}");
                    }
                }, 'JSON');
            }else{
                layer.close(index);
                layer.msg(res.msg);
            }
        }, 'JSON');
    });
</script>